Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥧[WEB-4164] - Adding Pricing Card CTA Arrow Icon #582

Merged
merged 2 commits into from
Dec 20, 2024
Merged

Conversation

aralovelace
Copy link
Contributor

@aralovelace aralovelace commented Dec 19, 2024

Jira Ticket Link / Motivation

WEB-4164 Add IconColor for the LinkButton and add rightIcon on all Pricing Cards CTA

Summary of changes

This pull request introduces several changes to the Button, LinkButton, and Pricing components to support customizable icon colors. The most important changes include adding a new iconColor prop to these components and updating their usage in relevant files.

Button and LinkButton components:

Pricing component:

How do you manually test this?

Reviewer Tasks (optional)

Merge/Deploy Checklist

  • Written automated tests for implemented features/fixed bugs
  • Rebased and squashed commits
  • Commits have clear descriptions of their changes
  • Checked for any performance regressions

Frontend Checklist

  • No frontend changes in this PR
  • Added before/after screenshots for changes
  • Tested on different platforms/browsers with Browserstack
  • Compared with the initial design / our brand guidelines
  • Checked the code for accessibility issues (VoiceOver User Guide)?

Summary by CodeRabbit

  • New Features

    • Introduced an iconColor property for buttons and links, allowing customization of icon colors.
    • Enhanced PricingCards to utilize the new iconColor property for call-to-action buttons.
  • Bug Fixes

    • Updated call-to-action properties for pricing plans to include specific icon colors.
  • Documentation

    • Updated type definitions to reflect the addition of the iconColor property in relevant components.

@aralovelace aralovelace self-assigned this Dec 19, 2024
Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces an iconColor property across multiple components in the core UI library, specifically for buttons and pricing cards. The changes enable dynamic icon color specification for buttons, allowing more granular styling control. The modification spans several files including Button.tsx, LinkButton.tsx, PricingCards.tsx, data.tsx, and types.ts, consistently implementing the new iconColor property with support for color classes and theme sets.

Changes

File Change Summary
src/core/Button.tsx Added optional iconColor property to ButtonPropsBase type
src/core/LinkButton.tsx Added optional iconColor property to LinkButtonProps type
src/core/Pricing/PricingCards.tsx Updated LinkButton to use iconColor and added rightIcon
src/core/Pricing/data.tsx Updated cta objects with iconColor for Free, Standard, and Pro plans
src/core/Pricing/types.ts Added optional iconColor to PricingDataFeatureCta type

Assessment against linked issues

Objective Addressed Explanation
Pricing Card Update [WEB-4164]

Possibly related PRs

Suggested labels

review

Suggested reviewers

  • jamiehenson
  • kennethkalmer

Poem

🐰 Buttons dressed in colors bright,
Icons dancing left and right,
With iconColor now in sight,
Our UI leaps to new delight!
Coding magic takes its flight! 🎨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/core/Button.tsx (1)

Line range hint 98-112: Button component is not passing iconColor to commonButtonInterior.

The Button component destructures and passes various props but misses the iconColor prop, which means icon colors won't work in the base Button component.

 const Button: React.FC<PropsWithChildren<ButtonProps>> = ({
   variant = "primary",
   size,
   leftIcon,
   rightIcon,
   children,
   className,
+  iconColor,
   ...rest
 }) => {
   return (
     <button
       {...commonButtonProps({ variant, size, leftIcon, rightIcon, className })}
       {...(rest as React.ButtonHTMLAttributes<HTMLButtonElement>)}
     >
-      {commonButtonInterior({ leftIcon, rightIcon, children })}
+      {commonButtonInterior({ leftIcon, rightIcon, iconColor, children })}
     </button>
   );
 };
🧹 Nitpick comments (2)
src/core/Button.tsx (1)

92-94: Consider using undefined instead of empty string for additionalCSS.

Using an empty string for additionalCSS when iconColor is not provided might not be the best approach. Consider using undefined instead, which better represents the absence of a value.

-      {leftIcon ? <Icon name={leftIcon} additionalCSS={iconColor || ''} /> : null}
+      {leftIcon ? <Icon name={leftIcon} additionalCSS={iconColor} /> : null}
-      {rightIcon ? <Icon name={rightIcon} additionalCSS={iconColor || ''} /> : null}
+      {rightIcon ? <Icon name={rightIcon} additionalCSS={iconColor} /> : null}
src/core/Pricing/data.tsx (1)

Line range hint 171-175: Consider adding iconColor to Enterprise plan CTA

The Enterprise plan's CTA is missing the iconColor property while all other plans have it. Consider adding it using the orange theme to maintain consistency with the Enterprise plan's color scheme.

 cta: {
   text: "Contact us",
   url: "/contact",
+  iconColor: "text-orange-600 dark:text-orange-600",
 },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec3d114 and 4573989.

📒 Files selected for processing (5)
  • src/core/Button.tsx (3 hunks)
  • src/core/LinkButton.tsx (3 hunks)
  • src/core/Pricing/PricingCards.tsx (1 hunks)
  • src/core/Pricing/data.tsx (3 hunks)
  • src/core/Pricing/types.ts (1 hunks)
🔇 Additional comments (5)
src/core/Pricing/types.ts (1)

17-17: LGTM! Type definition is well-structured.

The iconColor property is correctly typed as optional and uses the appropriate color types (ColorClass | ColorThemeSet).

src/core/Button.tsx (1)

32-35: LGTM! Property documentation is clear.

The JSDoc comments clearly document the purpose of the iconColor property.

src/core/LinkButton.tsx (1)

8-8: LGTM! Implementation is correct and consistent.

The LinkButton component correctly:

  • Imports the necessary color types
  • Adds the iconColor property to its props
  • Destructures and passes the property to commonButtonInterior

Also applies to: 13-13, 25-25, 52-52

src/core/Pricing/data.tsx (1)

17-21: LGTM! Consistent color theming across pricing tiers

The iconColor values are well-aligned with each plan's visual hierarchy:

  • Free plan uses neutral colors
  • Standard/Pro plans use blue to indicate premium status

Also applies to: 76-76, 128-132

src/core/Pricing/PricingCards.tsx (1)

195-196: LGTM! Clean implementation of icon customization

The addition of rightIcon and iconColor props is well-implemented:

  • Properly passes the iconColor from the cta object
  • Consistently uses the arrow icon across all CTAs

@aralovelace
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/core/Button.tsx (2)

89-94: Consider renaming additionalCSS to better reflect its purpose.

While the implementation is correct, the prop name additionalCSS on the Icon component might be misleading since we're specifically passing a color value. Consider renaming it to something more specific like colorClass or themeColor to better reflect its purpose.


Line range hint 1-117: Document the new iconColor feature in component documentation.

Since this is a core UI component, consider updating the component's documentation (e.g., Storybook stories, README, or design system documentation) to showcase the new iconColor feature and provide usage examples.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4573989 and 15c234e.

📒 Files selected for processing (5)
  • src/core/Button.tsx (4 hunks)
  • src/core/LinkButton.tsx (3 hunks)
  • src/core/Pricing/PricingCards.tsx (1 hunks)
  • src/core/Pricing/data.tsx (3 hunks)
  • src/core/Pricing/types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/core/Pricing/types.ts
  • src/core/LinkButton.tsx
  • src/core/Pricing/PricingCards.tsx
  • src/core/Pricing/data.tsx
🔇 Additional comments (2)
src/core/Button.tsx (2)

5-5: LGTM! Well-documented type definition.

The new iconColor property is properly typed and documented. Making it optional maintains backward compatibility.

Also applies to: 32-35


106-106: Verify the impact on existing button styles.

The implementation correctly forwards the iconColor prop to commonButtonInterior. However, let's verify that this change doesn't affect existing button styles where iconColor isn't specified.

Also applies to: 114-114

✅ Verification successful

No impact on existing button styles - implementation is safe

The iconColor prop is correctly implemented and won't affect existing button styles because:

  • It's properly forwarded through commonButtonInterior to the Icon component as additionalCSS
  • Existing button usage in the codebase shows iconColor is already being used in multiple places (PricingCards, ProductTile) with specific color values
  • When iconColor is not specified, the Icon component will render without the additionalCSS prop, maintaining the default styling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing button usage to ensure backward compatibility
rg -t tsx -t jsx "Button.*>|LinkButton.*>" --no-heading

Length of output: 85


Script:

#!/bin/bash
# Search for Button component usage patterns
rg --type-add 'ts:*.{ts,tsx}' --type-add 'jsx:*.jsx' -t ts -t jsx "<Button|<LinkButton" -A 2

# Check the Button component implementation
ast-grep --pattern 'const Button = ({ $$$props$$$ }: ButtonProps) => {
  $$$
}'

# Check if iconColor has a default value or is optional in the type definition
ast-grep --pattern 'interface ButtonProps {
  $$$
  iconColor?: $_
  $$$
}'

Length of output: 2045


Script:

#!/bin/bash
# Check ButtonProps interface definition
ast-grep --pattern 'interface ButtonProps {
  $$$
}'

# Check commonButtonInterior implementation
ast-grep --pattern 'const commonButtonInterior = ($$$) => {
  $$$
}'

# Look for any existing iconColor usage
rg --type-add 'ts:*.{ts,tsx}' -t ts 'iconColor.*=|iconColor:' -B 1 -A 1

Length of output: 2703

Copy link
Member

@jamiehenson jamiehenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Well remembered updating LinkButton as well. I've just replaced the commit bumping to the dev package version with one bumping to 15.1.11 instead - this is good to go so will release.

@jamiehenson jamiehenson merged commit d10070d into main Dec 20, 2024
4 checks passed
@jamiehenson jamiehenson deleted the WEB-4164 branch December 20, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants